<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>win10环境 jenkins+docker+github搭建前端持续集成环境 | 欢迎来到小羽的博客</title>
    <meta name="generator" content="VuePress 1.5.0">
    <link rel="icon" href="/favicon.ico">
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b61fe05f9bcd9cda05e839091f9a55a4";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
    <script type="text/javascript" src="/push.js"></script>
    <script type="text/javascript" src="/bdseo.js"></script>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    <link rel="preload" href="/assets/css/0.styles.535c5086.css" as="style"><link rel="preload" href="/assets/js/app.14e3b6f2.js" as="script"><link rel="preload" href="/assets/js/3.38ef4e4c.js" as="script"><link rel="preload" href="/assets/js/1.dd4aade8.js" as="script"><link rel="preload" href="/assets/js/4.6cf77dfa.js" as="script"><link rel="prefetch" href="/assets/js/10.7327de6d.js"><link rel="prefetch" href="/assets/js/11.dbb0142d.js"><link rel="prefetch" href="/assets/js/12.b0df0a98.js"><link rel="prefetch" href="/assets/js/13.478ebb6f.js"><link rel="prefetch" href="/assets/js/14.5b94084a.js"><link rel="prefetch" href="/assets/js/15.159d1a32.js"><link rel="prefetch" href="/assets/js/16.cf37c681.js"><link rel="prefetch" href="/assets/js/17.61f89c90.js"><link rel="prefetch" href="/assets/js/18.52aae943.js"><link rel="prefetch" href="/assets/js/19.152fd37e.js"><link rel="prefetch" href="/assets/js/20.ce91f28e.js"><link rel="prefetch" href="/assets/js/21.47bc5b36.js"><link rel="prefetch" href="/assets/js/22.4bb2e24d.js"><link rel="prefetch" href="/assets/js/23.8156f657.js"><link rel="prefetch" href="/assets/js/24.867f6f46.js"><link rel="prefetch" href="/assets/js/25.1195288f.js"><link rel="prefetch" href="/assets/js/26.87eb9ee8.js"><link rel="prefetch" href="/assets/js/27.f67176ce.js"><link rel="prefetch" href="/assets/js/28.9574af6a.js"><link rel="prefetch" href="/assets/js/29.ce6e5d4c.js"><link rel="prefetch" href="/assets/js/30.5a16f9ff.js"><link rel="prefetch" href="/assets/js/31.d9981107.js"><link rel="prefetch" href="/assets/js/32.e0da40e8.js"><link rel="prefetch" href="/assets/js/33.f50cc0ef.js"><link rel="prefetch" href="/assets/js/34.6d343a0b.js"><link rel="prefetch" href="/assets/js/35.6e3a0c31.js"><link rel="prefetch" href="/assets/js/36.38b9af99.js"><link rel="prefetch" href="/assets/js/37.87aede0d.js"><link rel="prefetch" href="/assets/js/5.c81d3913.js"><link rel="prefetch" href="/assets/js/6.8fadf7af.js"><link rel="prefetch" href="/assets/js/7.bb84db9a.js"><link rel="prefetch" href="/assets/js/8.d9edba17.js"><link rel="prefetch" href="/assets/js/9.c228f55c.js">
    <link rel="stylesheet" href="/assets/css/0.styles.535c5086.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-dad8a512><div data-v-dad8a512><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-dad8a512 data-v-dad8a512><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-64685f0e data-v-dad8a512 data-v-dad8a512><h3 class="title" style="display:none;" data-v-64685f0e data-v-64685f0e>欢迎来到小羽的博客</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-64685f0e data-v-64685f0e><input type="password" value="" data-v-64685f0e> <span data-v-64685f0e>Konck! Knock!</span> <button data-v-64685f0e>OK</button></label> <div class="footer" style="display:none;" data-v-64685f0e data-v-64685f0e><span data-v-64685f0e><i class="iconfont reco-theme" data-v-64685f0e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-64685f0e>vuePress-theme-reco</a></span> <span data-v-64685f0e><i class="iconfont reco-copyright" data-v-64685f0e></i> <a data-v-64685f0e><span data-v-64685f0e>小羽</span>
            
          <!---->
          2020
        </a></span></div></div> <div class="hide" data-v-dad8a512><header class="navbar" data-v-dad8a512><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/logo.png" alt="欢迎来到小羽的博客" class="logo"> <span class="site-name">欢迎来到小羽的博客</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/前端/" class="nav-link"><i class="iconfont undefined"></i>
  前端
</a></li><li class="dropdown-item"><!----> <a href="/categories/安全/" class="nav-link"><i class="iconfont undefined"></i>
  安全
</a></li><li class="dropdown-item"><!----> <a href="/categories/网络/" class="nav-link"><i class="iconfont undefined"></i>
  网络
</a></li><li class="dropdown-item"><!----> <a href="/categories/运维/" class="nav-link"><i class="iconfont undefined"></i>
  运维
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      其他
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://github.com/lyff1006" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  Github
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://gitee.com/xiaoyu-web" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-mayun"></i>
  Gitee
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/fly821760648" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-csdn"></i>
  CSDN
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://juejin.im/user/3597257778926973" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-juejin"></i>
  掘金
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://www.jianshu.com/u/4ab50cbafc3f" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-jianshu"></i>
  简书
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-dad8a512></div> <aside class="sidebar" data-v-dad8a512><div class="personal-info-wrapper" data-v-ca798c94 data-v-dad8a512><img src="/logo.png" alt="author-avatar" class="personal-img" data-v-ca798c94> <h3 class="name" data-v-ca798c94>
    小羽
  </h3> <div class="num" data-v-ca798c94><div data-v-ca798c94><h3 data-v-ca798c94>22</h3> <h6 data-v-ca798c94>文章</h6></div> <div data-v-ca798c94><h3 data-v-ca798c94>35</h3> <h6 data-v-ca798c94>标签</h6></div></div> <hr data-v-ca798c94></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/前端/" class="nav-link"><i class="iconfont undefined"></i>
  前端
</a></li><li class="dropdown-item"><!----> <a href="/categories/安全/" class="nav-link"><i class="iconfont undefined"></i>
  安全
</a></li><li class="dropdown-item"><!----> <a href="/categories/网络/" class="nav-link"><i class="iconfont undefined"></i>
  网络
</a></li><li class="dropdown-item"><!----> <a href="/categories/运维/" class="nav-link"><i class="iconfont undefined"></i>
  运维
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      其他
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://github.com/lyff1006" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  Github
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://gitee.com/xiaoyu-web" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-mayun"></i>
  Gitee
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/fly821760648" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-csdn"></i>
  CSDN
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://juejin.im/user/3597257778926973" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-juejin"></i>
  掘金
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://www.jianshu.com/u/4ab50cbafc3f" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-jianshu"></i>
  简书
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <!----> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-64685f0e data-v-dad8a512><h3 class="title" style="display:none;" data-v-64685f0e data-v-64685f0e>win10环境 jenkins+docker+github搭建前端持续集成环境</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-64685f0e data-v-64685f0e><input type="password" value="" data-v-64685f0e> <span data-v-64685f0e>Konck! Knock!</span> <button data-v-64685f0e>OK</button></label> <div class="footer" style="display:none;" data-v-64685f0e data-v-64685f0e><span data-v-64685f0e><i class="iconfont reco-theme" data-v-64685f0e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-64685f0e>vuePress-theme-reco</a></span> <span data-v-64685f0e><i class="iconfont reco-copyright" data-v-64685f0e></i> <a data-v-64685f0e><span data-v-64685f0e>小羽</span>
            
          <!---->
          2020
        </a></span></div></div> <div data-v-dad8a512><main class="page"><div class="page-title" style="display:none;"><h1>win10环境 jenkins+docker+github搭建前端持续集成环境</h1> <hr> <div data-v-aa64b9d0><i class="iconfont reco-account" data-v-aa64b9d0><span data-v-aa64b9d0>小羽</span></i> <i class="iconfont reco-date" data-v-aa64b9d0><span data-v-aa64b9d0>2020-07-19</span></i> <!----> <i class="iconfont reco-tag tags" data-v-aa64b9d0><span class="tag-item" data-v-aa64b9d0>jenkins</span><span class="tag-item" data-v-aa64b9d0>docker</span><span class="tag-item" data-v-aa64b9d0>github</span><span class="tag-item" data-v-aa64b9d0>持续集成</span><span class="tag-item" data-v-aa64b9d0>win10</span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><h2 id="_1-docker安装"><a href="#_1-docker安装" class="header-anchor">#</a> 1.docker安装</h2> <p>关于docker的安装，没啥好说的，直接官网下载然后直接傻瓜式安装即可（以前有装过vm等虚拟机的童鞋记得把虚拟机卸载了，然后重启，接着开启win10的hyper-v虚拟机，否则安装会报错）。https://www.docker.com/get-started</p> <h2 id="_2-安装jenkins"><a href="#_2-安装jenkins" class="header-anchor">#</a> 2.安装jenkins</h2> <h3 id="_2-1-下载jenkinsjenkins"><a href="#_2-1-下载jenkinsjenkins" class="header-anchor">#</a> 2.1 下载jenkinsjenkins</h3> <p>下载jenkins的win10版本</p> <p><img src="/assets/img/image-20200722000151974.8144cc4d.png" alt="image-20200722000151974"></p> <h3 id="_2-2-安装jenkins"><a href="#_2-2-安装jenkins" class="header-anchor">#</a> 2.2 安装jenkins</h3> <p>这一步没啥好说的，选择好jenkins的安装路径，然后傻瓜式安装jenkins</p> <h3 id="_2-3-进入jinkins"><a href="#_2-3-进入jinkins" class="header-anchor">#</a> 2.3 进入jinkins</h3> <p>容器创建启动完毕后，在url地址中输入localhost:6701(你映射的端口，默认是8080，这里本人修改为6701端口了)，即可进入jenkins。jenkins第一次启动时间会比较久请耐心等待。</p> <p>然后通过提示将密码复制在下方的密码框中</p> <p><img src="/assets/img/image-20200705005834949.8fe3ddd0.png" alt="image-20200705005834949"></p> <h3 id="_2-4-安装jenkins插件"><a href="#_2-4-安装jenkins插件" class="header-anchor">#</a> 2.4 安装jenkins插件</h3> <p>好了，找到密码了，然后就可以进入jenkins了，咦，不对，这又是个啥？噢，原来是插件安装，我们就直接选择推荐的插件就可以了，然后又是漫长的等待。</p> <p>ps：小伙伴们觉得慢的话可以使用国内源进行加速，进入配置目录（自己的jenkins安装路劲/jenkins_workplace/updates）。将所有的jenkins源替换为清华源</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>http://updates.jenkins-ci.org/download/plugins/
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language- line-numbers-mode"><pre class="language-text"><code>https://mirrors.tuna.tsinghua.edu.cn/jenkins/plugins/
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="/assets/img/image-20200722005548588.e06b6119.png" alt="image-20200722005548588"></p> <p><img src="/assets/img/image-20200705011236983.90cf1573.png" alt="image-20200705011236983"></p> <h3 id="_2-5-设置账号密码"><a href="#_2-5-设置账号密码" class="header-anchor">#</a> 2.5 设置账号密码</h3> <p>插件装好了，就可以进入jenkins中设置账号和密码了，然后剩下的步骤都直接默认即可。然后终于看到了jenkins的控制台了，不容易啊，铁子们~</p> <p><img src="/assets/img/image-20200705111039130.6068bea3.png" alt="image-20200705111039130"></p> <p><img src="/assets/img/image-20200705111340974.f165f1ed.png" alt="image-20200705111340974"></p> <h3 id="_2-6-配置node环境"><a href="#_2-6-配置node环境" class="header-anchor">#</a> 2.6 配置node环境</h3> <p>（1）安装node插件</p> <p>进入设置，manage plugin 中搜索node，然后安装，安装完后重启jenkins的docker镜像</p> <p><img src="/assets/img/image-20200706223840066.806c8103.png" alt="image-20200706223840066"></p> <p>（2）进入设置-&gt;全局设置，添加node环境</p> <p><img src="/assets/img/image-20200720231731131.b03c2cf0.png" alt="image-20200720231731131"></p> <h2 id="_3-结合github中的webhook配置持续集成"><a href="#_3-结合github中的webhook配置持续集成" class="header-anchor">#</a> 3.结合github中的webhook配置持续集成</h2> <h3 id="_3-1-创建github密钥"><a href="#_3-1-创建github密钥" class="header-anchor">#</a> 3.1 创建github密钥</h3> <p><img src="/assets/img/image-20200705012104073.826f0131.png" alt="image-20200705012104073"></p> <h3 id="_3-2-jenkins创建项目"><a href="#_3-2-jenkins创建项目" class="header-anchor">#</a> 3.2 jenkins创建项目</h3> <h4 id="_3-2-1-新建项目"><a href="#_3-2-1-新建项目" class="header-anchor">#</a> 3.2.1 新建项目</h4> <p>我们先来创建一个新的项目，输入项目名称后点击确定</p> <p><img src="/assets/img/image-20200705121522710.cd07e565.png" alt="image-20200705121522710"></p> <p><img src="/assets/img/image-20200705121628125.c7c1e379.png" alt="image-20200705121628125"></p> <h4 id="_3-2-2-项目持续集成配置"><a href="#_3-2-2-项目持续集成配置" class="header-anchor">#</a> 3.2.2 项目持续集成配置</h4> <p>（1）输入github项目地址，指定分支那里是指将要构建的项目分支默认为master。然后把github hook trigger for giiscm polling（这个选项是为了后面的自动化持续集成做准备）</p> <p><img src="/assets/img/image-20200705151913109.86deb0e7.png" alt="image-20200705151913109"></p> <p>（2）credentials中添加github账号和密码</p> <p><img src="/assets/img/image-20200705151223338.16784b6c.png" alt="image-20200705151223338"></p> <p>（3）选择node环境</p> <p><img src="/assets/img/image-20200721011019736.fbe3ecb8.png" alt="image-20200721011019736"></p> <p>（4）添加构建步骤</p> <p><img src="/assets/img/image-20200721011053933.881b80e7.png" alt="image-20200721011053933"></p> <p>（5）构建测试</p> <p>保存后，点击build now即开始构建，点击下方的序号可以查看我们的构建的工程</p> <p><img src="/assets/img/image-20200721011150445.e770145b.png" alt="image-20200721011150445"></p> <h3 id="_3-3-结合ngrok部署内网穿透服务"><a href="#_3-3-结合ngrok部署内网穿透服务" class="header-anchor">#</a> 3.3 结合ngrok部署内网穿透服务</h3> <p>众所周知知道ipv4资源紧缺，运营商也一般都不会给我们配备公网ip。因此想让我们的服务可以从外网进行访问就需要部署内网穿透服务（当然也可以使用ipv6，但是目前还不算完善，很多地方ipv6的网络还不全）</p> <p>1.注册ngrok账号</p> <p>http://www.ngrok.cc/</p> <p>2.隧道管理，选择免费服务器</p> <p><img src="/assets/img/image-20200720215537254.b140e7b1.png" alt="image-20200720215537254"></p> <p>3.填写相关信息，其中本地端口哪里对应的是从docker中映射出来的端口（本文2.2节）</p> <p><img src="/assets/img/image-20200720215811389.517a4c97.png" alt="image-20200720215811389"></p> <p>4.下载ngrok客服端，输入隧道id，开启ngrok穿透服务</p> <p><img src="/assets/img/image-20200720220047814.a09c906c.png" alt="image-20200720220047814"></p> <p><img src="/assets/img/image-20200720220358201.f98a2468.png" alt="image-20200720220358201"></p> <p><img src="" alt="image-20200720220602519"></p> <p><img src="" alt="image-20200720220750847"></p> <p>5.测试内网穿透是否成功</p> <p>在浏览器中输入ngrok给我们提供的url地址，如果可以进入jenkins的页面说明我们已经成功穿透到公网了</p> <h3 id="_3-4-结合webhook"><a href="#_3-4-结合webhook" class="header-anchor">#</a> 3.4 结合webhook</h3> <p>（1）进入github相关项目的setting-&gt;webhooks</p> <p>（2）添加webhook</p> <p><img src="/assets/img/image-20200720230531176.a9f5f812.png" alt="image-20200720230531176"></p> <p><img src="/assets/img/image-20200720230927808.458be813.png" alt="image-20200720230927808"></p> <p>（4）在我们的vue工程文件中添加dockerfile和nginx.conf</p> <p>（5）修改项目的构建步骤，修改为通过dockerfile进行构建。然后随便在自己的项目中修改一些东西，然后推送到github上的release分支。回到jenkins中，可以发现项目已经在进行自动构建了，查看构建的结果。发现可以通过localhost:6801对刚刚构建好的项目进行访问，到此前端的自动化构建完成。</p> <p><img src="/assets/img/image-20200722004300195.a1ddb510.png" alt="image-20200722004300195"></p> <p><img src="/assets/img/image-20200722004806197.840aaaf1.png" alt="image-20200722004806197"></p> <p><img src="/assets/img/image-20200722004849582.a33f4993.png" alt="image-20200722004849582"></p></div> <footer class="page-edit" style="display:none;"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">2020-8-19 9:23:16</span></div></footer> <!----> <!----> <ul class="side-bar sub-sidebar-wrapper" style="width:12rem;" data-v-40a3448a><li class="level-2" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_1-docker安装" class="sidebar-link" data-v-40a3448a>1.docker安装</a></li><li class="level-2" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_2-安装jenkins" class="sidebar-link" data-v-40a3448a>2.安装jenkins</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_2-1-下载jenkinsjenkins" class="sidebar-link" data-v-40a3448a>2.1 下载jenkinsjenkins</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_2-2-安装jenkins" class="sidebar-link" data-v-40a3448a>2.2 安装jenkins</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_2-3-进入jinkins" class="sidebar-link" data-v-40a3448a>2.3 进入jinkins</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_2-4-安装jenkins插件" class="sidebar-link" data-v-40a3448a>2.4 安装jenkins插件</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_2-5-设置账号密码" class="sidebar-link" data-v-40a3448a>2.5 设置账号密码</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_2-6-配置node环境" class="sidebar-link" data-v-40a3448a>2.6 配置node环境</a></li><li class="level-2" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_3-结合github中的webhook配置持续集成" class="sidebar-link" data-v-40a3448a>3.结合github中的webhook配置持续集成</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_3-1-创建github密钥" class="sidebar-link" data-v-40a3448a>3.1 创建github密钥</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_3-2-jenkins创建项目" class="sidebar-link" data-v-40a3448a>3.2 jenkins创建项目</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_3-3-结合ngrok部署内网穿透服务" class="sidebar-link" data-v-40a3448a>3.3 结合ngrok部署内网穿透服务</a></li><li class="level-3" data-v-40a3448a><a href="/blogs/%E8%BF%90%E7%BB%B4/2020/jenkins+docker+github%E6%90%AD%E5%BB%BA%E5%89%8D%E7%AB%AF%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%8E%AF%E5%A2%83.html#_3-4-结合webhook" class="sidebar-link" data-v-40a3448a>3.4 结合webhook</a></li></ul></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-44bd5a18 data-v-44bd5a18><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-44bd5a18><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-44bd5a18></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-44bd5a18></path></svg></div></div></div>
    <script src="/assets/js/app.14e3b6f2.js" defer></script><script src="/assets/js/3.38ef4e4c.js" defer></script><script src="/assets/js/1.dd4aade8.js" defer></script><script src="/assets/js/4.6cf77dfa.js" defer></script>
  </body>
</html>
